import operate from '@dfeidao/atom-nodejs/db/operate';
import doc from "@dfeidao/atom-nodejs/msg/doc-code";
import sys_date from '@dfeidao/atom-nodejs/msg/sys-date';

import { systemid } from '../atom/config';
interface Message {
	obj: {
		review_content: string;
		student_name: string;
		grade: string;
		class_name: string;
		section: number;
		subject_name: string;
		student_no: string;
		date: number;
		teacher_no: string;
		teacher_name: string;
	};
	productid: string;
	username: string;
	review_time: number;
}

export default async function atom(msg: Message, action_id: string, session_id: string) {
	const time = await sys_date(action_id, session_id);
	const { exec, insert } = await operate(action_id, session_id, systemid);
	const r = await doc(action_id, session_id, systemid, "BM0016045", "", 1);
	insert('review_after_class', {
		review_num: r.result,
		review_content: msg.obj.review_content,
		student_name: msg.obj.student_name,
		grade: msg.obj.grade,
		class_name: msg.obj.class_name,
		section: msg.obj.section,
		subject_name: msg.obj.subject_name,
		review_time: time,
		date: msg.obj.date,
		// review_status: "1",
		student_no: msg.obj.student_no,
		teacher_no: msg.obj.teacher_no,
		teacher_name: msg.obj.teacher_name,
		productid: msg.productid
	});

	const res = await exec();
	return res;
	// if (ret.code === 1) {
	// 	return { code: 1, data: "success" };
	// } else {
	// 	return { code: 0, data: "fail" };
	// }
}
